﻿using Restaurant.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace Restaurant.Client.Controls
{
    /// <summary>
    /// u_FoodItem.xaml 的交互逻辑
    /// </summary>
    public partial class u_FoodItem : UserControl
    {
        private Food _food;

        /// <summary>
        /// 当前项数据
        /// </summary>
        public Food Food
        {
            get => _food;
            set
            {
                _food = value;
                tb_Name.Text = Food.FoodName;
            }

        }

        public delegate void ThisClick(u_FoodItem sender);
        public event ThisClick Edit;
        public event ThisClick Delete;
        public u_FoodItem()
        {
            InitializeComponent();
        }
        public u_FoodItem(Food food)
            : this()
        {
            Food = food;
        }

        private void btn_Edit_Click(object sender, RoutedEventArgs e)
        {
            Edit?.Invoke(this);
        }

        private void btn_Delete_Click(object sender, RoutedEventArgs e)
        {
            Delete?.Invoke(this);
        }
    }
}
